<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="global.jsp" %>
<%
  int caiGouBiaoId = ParamUtils.getIntParameter(request,"CaiGouBiaoId", -1);
  if (caiGouBiaoId == -1){
	  out.println("参数错误");
      return ;
  }

      //
      CaiGouBiaoJia cgbj = new CaiGouBiaoJia(caiGouBiaoId);
      ArrayList sps = cgbj.GetCaiGouShangPings();
      ArrayList cggss = cgbj.GetCaiGouGongSis();
      int factorys = cggss.size();
      int productorys = sps.size();
    	
      int nCaiGouYuanId = cgbj.getYuanGongId();
      User caigouYuan = new User(nCaiGouYuanId);
      String strCaiGoyYuanName = caigouYuan.getXingMing();
	  
	  //int nUserQuanXian = UserManager.GetShenHeYuanQuanXianByUserID(pageUser.getYongHuMing());
      //System.out.println("nUserQuanXian:"+nUserQuanXian); 
	  //常用意见
       String cyyj = XiaLaLiebiaoInfos.getHtmlOption(XiaLaLiebiaoInfos.GetAllYiJian());
	   
	   //审核意见栏的宽度
      int nYiJianWidth = 30+factorys * 12;
    %>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采购比价单</title>

<style type="text/css">  
   body{margin:0px;}
   .fontff{
          TEXT-ALIGN:center;                   
   }
   .unbloud{   
            BORDER-RIGHT:   #000000   0px   solid;   BORDER-TOP:   #000000   0px   solid;   BORDER-LEFT:   #000000   0px   solid;   BORDER-BOTTOM:   #000000   1px   solid   
   }
   .unbloud_error{   
            BORDER-RIGHT:   #000000   0px   solid;   BORDER-TOP:   #000000   0px   solid;   BORDER-LEFT:   #000000   0px   solid;   BORDER-BOTTOM:   #ff0000   1px   solid   
   }
   .error{border:1px solid #ff0000;}
   .correct{font-size : 11px;}
   body,td,th,input {
	font-size: 12px;
   }
#productSearch_layer {
	position:absolute;
	padding:20px;
0 20px;	background: #D5D5D5;
	border:1px solid #999999;
	width:522px;
	height:234px;
	left:100px;
	top:138px;
	z-index:2;
}
    </style>
<!--media=print   这个属性可以在打印时有效--> 
<style   media=print> 
.Noprint{display:none;} 
.PageNext{page-break-after:   always;} 
</style> 
<link href="css/basic.css" rel="stylesheet" type="text/css" />
<link href="styleTable.css" type="text/css" rel="Stylesheet" />

<style type="text/css">
<!--
#cyyj {
	position:absolute;
	left:528px;
	top:485px;
	width:149px;
	height:38px;
	z-index:3;
}
-->
</style>
<script type="text/javascript"> 
 function changeval(obj1,obj2) {
   obj2.value = obj1.options[obj1.selectedIndex].value;
}
//显示商品查询
function displayDiv() 
{ 
  document.getElementById("productSearch_layer").style.display="block"; 
} 
//隐藏商品查询
function hiddenDiv() 
{ 
  document.getElementById("productSearch_layer").style.display="none"; 
}
//提交前做值检查 
function valueCheckOut(){
   var has_error = false;
   //比价部
   if (<%=pageUser.isBiJiaBu()%>){
     //商品数和厂家数
     var defaultPros = <%=factorys%>
     var defaultFacs = <%=productorys%>
     //完整性判断
     for (i = 1; i <= defaultPros; i++)
     {
	    //审核价不能为空
        for (j = 1; j <= defaultFacs; j++){
           temp_input = document.getElementById("sj"+i+"_" + j)
           temp_input_value = temp_input.value;   
           if ( temp_input_value == ""){
             has_error = true;
             temp_input.className = "error";
           }else{
             temp_input.className = "correct";
           }
        }
     }
     //总审核价
     for (j = 1; j <= defaultFacs; j++){
        //总价
        temp_input = document.getElementById("sjzj_" + j)
        temp_input_value = temp_input.value;   
        if ( temp_input_value == ""){
          has_error = true;
          temp_input.className = "error";
        }else{
          temp_input.className = "correct";
        }   
     }
   }
   
   if (has_error){
      alert("数据未填完整，请检查表单后重新提交！");
      return false;
   }
  return true;
}
</script>
<STYLE MEDIA="PRINT">    
	.only_print_view {display:none;}
</STYLE>
<STYLE MEDIA="SCREEN">    
	.only_print_view {display:block;}
</STYLE>
<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<OBJECT ID="ReYoPrint" CLASSID="CLSID:5C230622-45E5-4e3c-893C-3BFDDC4DB5E4"  codebase="ReYoPrint.cab" height="0" width="0"></OBJECT>
<script>
  ReYoPrint.MarginLeft=2;	//设置左边边距
  ReYoPrint.MarginRight=2;	//设置右边边距 
  ReYoPrint.MarginTop=2;	//设置上边边距
  ReYoPrint.MarginBottom=2;	//设置下边边距
  ReYoPrint.CopyCount=1;  	//打印份数
  ReYoPrint.PageHeader="";	//页眉
  ReYoPrint.PageFooter="";	//页脚
  ReYoPrint.IsLandScape=1;	//把页面设置为横向1
  //ReYoPrint.ContentURL="http://www.interdrp.com/print.html";
</script>
</head>

<body id="body" bgcolor="#FFFFFF">
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT> 
<div id="productSearch_layer" style="display:none;background:#E9E9E9">
<input type="button" onClick="hiddenDiv()" value="返回">
<iframe class="TBGen" style="top:2px" ID="UploadFiles" src="product_search.jsp" frameborder=0 scrolling=no width="500" height="300"> </iframe>
</div>

<form name="bjsh_form" method="post" action="sh_cgbj_deal.jsp?CaiGouBiaoId=<%=caiGouBiaoId %>"  onsubmit="return valueCheckOut()">
<table width="81%" border="1" cellpadding="2" cellspacing="1"  bgcolor="<%= tblBorderColor %>">
	<tr bgcolor="#FFFFFF">
		<td colspan="3">
		<table width="100%" height="40" border="0" cellpadding="2"
			cellspacing="2">
			<tr bgcolor="#FFFFFF">
				<td width="73%">
				<div align="center"><%=cgbj.getMingCheng() %> 采购比价单</div></td>
				<td width="27%">单据编号： <%=cgbj.getDanJuBiaoHao()%></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr bgcolor="#FFFFFF">
		<td colspan="3">
		<table width="100%" border="0" cellpadding="2" cellspacing="2">
			<tr>
				<td width="50%">
					<label align = "left">申购项目：<%=XiangMuManager.getxiangMuByID(cgbj.getXiangMuId()).getMingCheng() %></label>
		        </td>
		        <td width="23%">
		        	<label align = "left">类别：<%=cgbj.getBiaoLeiXingMing() %> </label>
		        </td>
				<td width="27%">
					日期：<%=cgbj.getChuangJianShiJian() %>
				</td>
			</tr>
		</table>
	  </td>
	</tr>
	<tr bgcolor="#FFFFFF">
		<td width="2%">
		<div align="center">情况汇总</div>
	  </td>
		<td width="34%" valign="top">
		<table id="testTbl" cellspacing="0" border="0">
		
				<tr id="tr0">
				<td width="12" class="tdOnlyRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="96" class="tdOnlyLeftAndRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="56" id="b11" class="tdOnlyLeftAndRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="28" id="b11" class="tdOnlyLeftAndRight">
				<div align="center">&nbsp;</div>
				</td>
				<td width="48" id="b11" class="tdOnlyLeftAndRight">
				<div align="center" style="overflow-x:auto;width:35px">&nbsp;</div>
				</td>
		<%
        Iterator cggs_iter1 = cggss.iterator();
        while (cggs_iter1.hasNext()){
        	CaiGouGongSi gs = (CaiGouGongSi)cggs_iter1.next();
        	out.println("<td bgcolor=\"#FFFFFF\" id=\"b11\" class=\"tdOnlyLeftAndRight\" colspan =\"2\">"+					
			        "<div align=\"center\">"+gs.getGongSimingCheng()+"</div>"+
		            "</td>");
        }

        %>
		<td class="tdOnlyLeft"><div align="center" style="overflow-x:auto;width:35px">&nbsp;</div></td>
		</tr>
		
			<tr id="tr0">
				<td width="12" class="tdLeftTop">
				<div align="center" >序号</div>
				</td>
				<td width="96"  class="tdTop">
				<div align="center" >品名</div>
				</td>
				<td width="56" id="b11"  class="tdTop">
				<div align="center" >规格型号</div>
				</td>
				<td width="28" id="b11"  class="tdTop">
				<div align="center">数量</div>
				</td>
				<td width="48" id="b11"  class="tdTop">
				<div align="center" style="overflow-x:auto;width:45px">计量单位</div>
				</td>
				<%
        			Iterator cggs_iter2 = cggss.iterator();
        			while (cggs_iter2.hasNext())
        			{
      					CaiGouGongSi gs = (CaiGouGongSi)cggs_iter2.next();
						out.println( "<td class=\"tdGeneral\"><div align=\"center\">报价</div></td><td class=\"tdGeneral\"><div align=\"center\">审价</div></td>");
       				}
        		%>
				<td  class="tdRightTop">历史价格</td>
			</tr>
			    <%
    Iterator iter = sps.iterator();
			    int i=1;
    while (iter.hasNext()){
    	//
    	CaiGouShangPing sp = (CaiGouShangPing)iter.next();
    	int caiGouShangPingId = sp.getCaiGouShangPingId();
    %>
			<tr id="tr1">
              <td align="center" width="20" class="tdLeft"><div align="center" style="overflow-x:auto;width:20px"><%=i %></div></td>
              <td width="120" class="tdMiddle"><div style="overflow-x:auto;width:150px"><%=sp.getMingCheng() %></div></td>
              <td id="b11" class="tdMiddle"><div style="overflow-x:auto;width:100px"><%=sp.getGuiGe() %></div></td>
              <td id="b11" class="tdMiddle"><div style="overflow-x:auto;width:50px"><%=sp.getShuLiang() %></div></td>
              <td id="b11" align="center" class="tdMiddle"><div style="overflow-x:auto;width:50px">
                <label><%=sp.getDanWei() %></label>
              </div></td>
              <%
						Iterator iter_gs = cggss.iterator();
						int j = 1;
						while (iter_gs.hasNext()) {
							CaiGouGongSi val = (CaiGouGongSi) iter_gs.next();
							//int  =m.get("");
							out
							.println("<td  id=\"b11\" class=\"tdMiddle\"><div align=\"center\" style=\"overflow-x:auto\">"
							
							+ cgbj.getGongSiBaoJia(caiGouShangPingId,
									val.getGongSiId())
							+ "</div></td><td class=\"tdMiddle\"> <div align=\"center\" style=\"overflow-x:auto\"> <input name=\"sj"
							+ i
							+ "_"
							+ j
							+ "\" type=\"text\" class=\"fontff\" id=\"sj"
							+ i
							+ "_"
							+ j
							+ "\" size=\"4\" value=\"" + cgbj.getShenHeBoaJia(caiGouShangPingId, val.getGongSiId())+ "\" "
							+ (pageUser.isBiJiaBu() ? " " : " readonly")
							+ "/></div></td>");
							j++;
						}
				%>
				<td class="tdRight"><%=sp.getLiShiJiaGe() %></td>
		  </tr>
			
	        <%  
	        			i++;
	  				} 
	  		%>
			<tr id="trzj">
			<td colspan="5" align="center"  class="tdLeft">总价</td>
				<%
		Iterator iter_gs = cggss.iterator();
				int k=1;
        while (iter_gs.hasNext()){
        	CaiGouGongSi val = (CaiGouGongSi)iter_gs.next();
        	//int  =m.get("");
        	out.println("<td  id=\"b11\" class=\"tdMiddle\"><div align=\"center\" style=\"overflow-x:auto\">" +
        	val.getZongBaoJia()+
			" </div></td><td class=\"tdMiddle\"><div align=\"center\" style=\"overflow-x:auto\"> <input name=\"sjzj_"
			+ k 
			+"\" type=\"text\" class=\"fontff\" id=\"sjzj_"
			+ k 
			+ "\" size=\"4\" value=\""
			+ val.getZongShenHeBaoJia()  
			+"\" " + (pageUser.isBiJiaBu() ? " " : " readonly") 
			+ "/></div></td>" );
        	k++;
        }
        %>
				<td class="tdRight">&nbsp;</td>
			</tr>
			<tr id="trlxr">
			<td colspan="5" align="center" class="tdLeftBottom">联系人(联系方式)</td>
				<%
        iter_gs = cggss.iterator();
        while (iter_gs.hasNext()){
        	CaiGouGongSi val = (CaiGouGongSi)iter_gs.next();
        	//int  =m.get("");
        	out.println("<td colspan=\"2\" id=\"b11\" class=\"tdBottom\"><div align=\"center\" style=\"overflow-x:auto;width:114px\">" +
        	val.getLianXirenHeFangshi()+  
        	" </div></td>");
        }
    %>
				<td class="tdRightBottom">&nbsp;</td>
			</tr>
		</table>
	  </td>
		<td width="64%" valign="top">
		<table width="196" border="0" cellspacing="0" >
			<tr>
				<td height="10" class="tdOnlyBottom">
				<div align="center">备注</div>
				</td>
			</tr>
			<tr height="180">
				<td valign="top" height="180" class="tdOnlyTop">
				<label> 
				<textarea name="YouBianBeiZhu"
					rows="<%=(5+productorys)%>" id="YouBianBeiZhu" <%=pageUser.isCaiGouYuan()?" readonly":"" %> 
					style="width:180;height:100%" >
					<%=cgbj.getYouBianBeiZhu() %>
					</textarea> 
			  </label></td>
			</tr>

		</table>
	  </td>
	</tr>
	<tr bgcolor="#FFFFFF">
		<td><span style="width: 12px">审核意见</span></td>
		<td colspan="2">
		<table width="100%" border="1">
			<tr height="90">
				<td width="24%"><span
					style="height: 40px; width: 150px; text-align: left;">技术备注：</span></td>
				<td width="76%"><textarea name="XiaMianBeiZhu" cols="<%=nYiJianWidth+20 %>" value="<%=cgbj.getXiaMianBeiZhu() %>"
					rows="3" id="XiaMianBeiZhu" <%=pageUser.isCaiGouYuan()?" readonly":"" %>
					style="width:100%;height:100%;">
					<%=cgbj.getXiaMianBeiZhu()%>
					</textarea></td>
			</tr>
			<tr height="90">
				<td><span style="width: 150px; height: 21px; text-align: left">项目组意见:</span></td>
				<td>&nbsp;
				<%
					if(	pageUser.isXiangMuZu())
					{
				%>
				  <table width="100%" border="0" cellspacing="1" cellpadding="1">
            		<tr height="80%">
            		<td>
				  		<textarea name="XiangMuZuYiJian" cols="<%=nYiJianWidth %>" rows="3"  type="text" size="50"
				  			style="width:100%;height:100%;"><%=cgbj.ShenHeXinXiParse( cgbj.getXiangMuZouYiJian(), true )%></textarea></td>
				  	</tr>
				  	<tr>
				 	 <td>
				    	<select name="s_cyyj" id="s_cyyj" width="100%" onChange="changeval(this,document.forms['bjsh_form'].XiangMuZuYiJian)" class="Noprint"
				    	style="width:100%;height:100%;">
						<option selected="selected">请选择</option> 
					  		<%=cyyj %>
                	    </select></td>
            	   	</tr>
       		 	  </table>
				<%
					}
					else
					{
				%>
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getXiangMuZouYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getXiangMuZouYiJian(), false )%></div></td>
                  </tr>
                </table>
				<% } %>
			  </td>
			</tr>
			<tr height="90">
				<td><span style="width: 150px; text-align: left;">采购部意见:</span></td>
				<td>&nbsp;<label><%
					if(	pageUser.isCaiGouBu())
					{
				%>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
            		<tr height="80%">
            		<td>
				  <textarea name="CaiGouBuYiJian" cols="<%=nYiJianWidth %>" rows="3"  type="text" size="50"
				  style="width:100%;height:100%;"> 
				  <%=cgbj.ShenHeXinXiParse( cgbj.getCaiGouBuYiJian(), true )%>
				  </textarea>
				  </td>
				  </tr>
				  <tr>
				 	 <td>
                     <select name="s_cgb" id="s_cgb" onChange="changeval(this,document.forms['bjsh_form'].CaiGouBuYiJian)" class="Noprint"
                    style="width:100%;height:100%;"> 
					  <option selected="selected">请选择</option> 
					  <%=cyyj  %>
				    </select>
				    </td>
           	      </tr>
       		 	  </table>
				<%
					}
					else
					{
				%>
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getCaiGouBuYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getCaiGouBuYiJian(), false )%></div></td>
                  </tr>
                </table>
				
				<% } %>
					</label></td>
			</tr>
			<tr height="90">
				<td><span style="width: 150px; text-align: left">比价部意见:</span></td>
				<td>&nbsp;
					
				<%
					if(	pageUser.isBiJiaBu())
					{
				%>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
            		<tr height="80%">
            		<td><textarea name="BiJiaBuYiJian" cols="0" rows="3"  type="text" size="50"
				 	 style="width:100%;height:100%;"><%=cgbj.ShenHeXinXiParse( cgbj.getBiJiaBuYiJian(), true )%></textarea>
				 	 </td>
				 	 </tr><tr>
				 	 <td><select name="s_bjb" id="s_bjb" onChange="changeval(this,document.forms['bjsh_form'].BiJiaBuYiJian)" class="Noprint"
				   	style="width:100%;height:100%;"> 
					  <option selected="selected">请选择</option> 
					  <%=cyyj %>
				    </select>
					 </td>
            		</tr>
       		 	</table>
				<%
					}
					else
					{
				%>
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getBiJiaBuYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getBiJiaBuYiJian(), false )%></div></td>
                  </tr>
                </table>
				
				<% } %>
			  </td>
			</tr>
			<tr height="90">
				<td><span style="width: 150px; text-align: left">中心总经理批示:</span></td>
				<td>&nbsp;<%
					if(	pageUser.isJingLi())
					{
				%>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
            		<tr height="80%">
            		<td>
				  <textarea name="ZhongXinJingLiYiJian" cols="<%=nYiJianWidth %>" rows="3"  type="text" size="50"
				  style="width:100%;height:100%;">
				  <%=cgbj.ShenHeXinXiParse( cgbj.getZhongXinJingLiYiJian(), true )%>
				  </textarea>
				   
				   	</td>
				 	 </tr><tr>
				 	 <td>
				   	<select name="s_zxjl" id="s_zxjl" onChange="changeval(this,document.forms['bjsh_form'].ZhongXinJingLiYiJian)" class="Noprint"
				   	style="width:100%;height:100%;"> 
					  <option selected="selected">请选择</option> 
					  <%=cyyj %>
				    </select>
				    
				     </td>
            		</tr>
       		 	</table>
				<%
					}
					else
					{
				%>
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getZhongXinJingLiYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getZhongXinJingLiYiJian(), false )%></div></td>
                  </tr>
                </table>
				
				<% } %>
			  </td>
			</tr>
			<tr height="90">
				<td><span style="width: 150px; text-align: left;">分管总裁批示:</span></td>
				<td>&nbsp;
				<%
					if(	pageUser.isZhongCai())
					{
				%>
				 <table width="100%" border="0" cellspacing="0" cellpadding="0">
            		<tr height="80%">
            		<td>
				  		<textarea name="FenGuanZongCaiYiJian" cols="0" rows="3"  type="text" size="50"
				  			style="width:100%;height:100%;">
				   			<%=cgbj.ShenHeXinXiParse( cgbj.getFenGuanZongCaiYiJian(), true )%>
				   		</textarea>
				   	</td>
			 	   </tr><tr>
				 	 <td>
				   		<select name="s_cyyj" id="s_cyyj" onChange="changeval(this,document.forms['bjsh_form'].FenGuanZongCaiYiJian)" class="Noprint"
				   			style="width:100%;height:100%;"> 
					  		<option selected="selected">请选择</option> 
					  		<%=cyyj %>
		    		   </select>   
                		</select>
				     </td>
            		</tr>
       		 	</table>
				<%
					}
					else
					{
				%>
				<table width="100%" border="0" cellspacing="1" cellpadding="1">
                  <tr>
                    <td><%=cgbj.ShenHeXinXiParse( cgbj.getFenGuanZongCaiYiJian(), true )%></td>
                  </tr>
                  <tr>
                    <td><div align="right">审核人：<%=cgbj.ShenHeXinXiParse( cgbj.getFenGuanZongCaiYiJian(), false )%></div></td>
                  </tr>
                </table>
				
				<% } %>
					</label></td>
			</tr>
		</table>
	  </td>
	</tr>
	<tr>
	<td colspan="3" align="right" bgcolor="#FFFFFF">
	 采购员： <%=strCaiGoyYuanName %>
	</td>
	</tr>
</table>
<br />
<label></label>
<label>
	<%
		if(	pageUser.isZhongCai())
		{
	%>
					<input
	type="submit" name="Submit" value="同意"/>
		<input
	type="submit" name="Submit" value="拒绝"/>
	
	<% }
		else if(pageUser.isJingLi())
		{
	%>
			<input
	type="submit" name="Submit" value="提交"/>
		<input
	type="submit" name="Submit" value="结束审批"/>
	<%  }
		else
		{
			if (!pageUser.isCaiGouYuan()){
	%>
			<input
			type="submit" name="Submit" value="提交" class="Noprint"/>
	<%
			}
		}%>
	
 <input type="button"
	onClick="displayDiv()" value="商品查询" class="Noprint"></label> <input name="row"
	type="hidden" id="row" value="7"> <input name="column "
	type="hidden" id="column " value="7"> <INPUT id=factorys
	type=hidden value=3 name=factorys> <input id=products
	type=hidden value=5 name=products>

</form>

</body>
</html>
